package com.pms.businesslogic;

import com.pms.platform.dao.UserDao;
import com.pms.platform.dto.User;

public class AuthenticationManager {
	public User validateLogin(String login,String password,String vendorCode) throws Exception{
		User user=null;
		try{

			user=UserDao.getInstance().findWhereLoginIdAndPasswordEquals(login, password);
			if(user!=null){
				if(!(user.getVendor_Code().equalsIgnoreCase(vendorCode))){
					user=null;
					throw new Exception(" Invalid Vendor Code For the given UserId.");
				}
			}else{
				throw new Exception(" Invalid User Name or Password.");
			}

		}catch (Exception e) {
			e.printStackTrace();
		}

		return user;
	}

}
